#!/usr/bin/env ansible-playbook
---
- hosts: localhost
  vars:
    ansible_ask_become_pass: true
    configs:
    - fish
    - git
    - nvim
    - starship
    - tmux

  tasks:
  - name: "Disable PC speaker in console"
    ansible.builtin.replace:
      path: /etc/inputrc
      regexp: '^#(set bell-style none)$'
      replace: '\1' 
    become: yes

  - name: "Enable TimesyncD"
    ansible.builtin.systemd:
      name: systemd-timesyncd
      enabled: yes
    become: yes

  - name: "Upgrade all packages"
    community.general.pacman:
      update_cache: yes
      upgrade: yes
    become: yes

  - name: "Create the `aur_builder` user"
    become: yes
    ansible.builtin.user:
      name: aur_builder
      create_home: yes
      group: wheel

  - name: "Allow the `aur_builder` user to run `sudo pacman` without a password"
    become: yes
    ansible.builtin.lineinfile:
      path: /etc/sudoers.d/11-install-aur_builder
      line: 'aur_builder ALL=(ALL) NOPASSWD: /usr/bin/pacman'
      create: yes
      validate: 'visudo -cf %s'

  - name: "Create symlink for configuration directories"
    ansible.builtin.file:
      src: "{{ playbook_dir }}/config/{{ item }}"
      dest: "~/.config/{{ item }}"
      state: link
      owner: 1000
      group: 1000
    loop: "{{ configs }}"

  - name: "Add usev rule for Dactyl"
    ansible.builtin.copy:
      src: "{{ playbook_dir }}/config/udev/dactyl.rules"
      dest: /etc/udev/rules.d/92-viia.rules
      owner: root
      group: root
      mode: '0644'
    become: yes

  - name: "Clone tmux-powerline"
    ansible.builtin.git:
      repo: 'https://github.com/erikw/tmux-powerline.git'
      dest: "~/.local/share/tmux-powerline"

  - name: "Install common packages"
    community.general.pacman:
      name: 
      - bash-completion # Programmable completion for the bash shell
      - bat # Cat clone with syntax highlighting and git integration
      - bind # A complete, highly portable implementation of the DNS protocol
      - bottom # A graphical process/system monitor
      - btop # A monitor of system resources, bpytop ported to C++ 
      - broot # Fuzzy Search + tree + cd
      - curl # It's fucking cURL, questions?
      - dust # A more intuitive version of du in rust
      - eza # ls replacement
      - fd # Simple, fast and user-friendly alternative to find
      - fish # Smart and user friendly shell intended mostly for interactive use
      - fisher # A package manager for the fish shell
      - fzf # Command-line fuzzy finder
      - go-yq # Portable command-line YAML processor
      - hub # cli interface for Github
      - jq # Command-line JSON processor
      - lazygit # Simple terminal UI for git commands
      - mediainfo # Supplies technical and tag information about a video or audio file (CLI interface)
      - neovim # Fork of Vim aiming to improve user experience, plugins, and GUIs
      - openbsd-netcat # TCP/IP swiss army knife. OpenBSD variant.
      - openvpn # An easy-to-use, robust and highly configurable VPN (Virtual Private Network)
      - ripgrep # A search tool that combines the usability of ag with the raw speed of grep
      - rmlint # Tool to remove duplicates and other lint, being much faster than fdupes
      - rsync #  A fast and versatile file copying tool for remote and local files
      - starship # The cross-shell prompt for astronauts
      - thefuck # Magnificent app which corrects your previous console command
      - tmux # A terminal multiplexer
      - unzip # For extracting and viewing files in .zip archives
      - p7zip # Command-line file archiver with high compression ratio
      - wget # Network utility to retrieve files from the Web
      - which # A utility to show the full path of commands
      - websocat # Command-line client for web sockets, like netcat/curl/socat for ws://
      - trash-cli # Command line trashcan (recycle bin) interface
      - pcmanfm-gtk3 # Extremely fast and lightweight file manager (GTK+ 3 version)
      - atool # A script for managing file archives of various types
      - lynx # A text browser for the World Wide Web
      update_cache: yes
      state: latest
    become: yes

  - name: "Set fish as default shell for current user"
    ansible.builtin.user:
      name: "{{ ansible_user_id }}"
      shell: /usr/bin/fish
    become: yes

  - name: "Install disk utilities"
    community.general.pacman:
      name: 
      - btrfs-progs # Btrfs filesystem utilities
      - lvm2 # Logical Volume Manager 2 utilities
      - mdadm # A tool for managing/monitoring Linux md device arrays, also known as Software RAID
      - ntfs-3g # NTFS filesystem driver and utilities
      - xfsprogs # XFS filesystem utilities
      state: latest
    become: yes

  - name: "Set email for mdmonitor service"
    ansible.builtin.lineinfile:
      path: /etc/mdadm.conf
      regexp: '^#MAILADDR'
      line: 'MAILADDR root'
      state: present
    become: yes

  - name: Instal Tmux Plugin Manager
    ansible.builtin.git:
      repo:  https://github.com/tmux-plugins/tpm.git
      dest: ~/.config/tmux/plugins/tpm
...
